#include "../httplib.h"
#include "AddPeople.pb.h"
#include "ContactException.h"
#include "contacts.hpp"
#include <iostream>
#include <string>
void menu()
{

    std::cout << "-----------------------------------------------------" << std::endl
              << "--------------- 请选择对通讯录的操作 ----------------" << std::endl
              << "------------------ 1、新增联系人 --------------------" << std::endl
              << "------------------ 2、删除联系人 --------------------" << std::endl
              << "------------------ 3、查看联系人列表 ----------------" << std::endl
              << "------------------ 4、查看联系人详细信息 ------------" << std::endl
              << "------------------ 0、退出 --------------------------" << std::endl
              << "-----------------------------------------------------" << std::endl;
}
typedef enum
{
    QUIT,
    ADDPEOPLE,
    DEL,
    FIND_ALL,
    FIND_ONE
} OPTION;

int main()
{

    Contact contact;
    try
    {
        int choose;
        do
        {
            menu();
            std::cout << "---> 请选择：";
            std::cin >> choose;
            std::cin.ignore(256, '\n');
            switch (choose)
            {
            case OPTION::ADDPEOPLE:
                contact.AddOnePeople();
                break;
            case OPTION::DEL:
                break;
            case OPTION::FIND_ALL:
                break;
            case OPTION::FIND_ONE:
                break;
            case OPTION::QUIT:
                std::cout << "退出程序" << std::endl;
                break;
            default:
                std::cout << "选择错误请重新输入" << std::endl;
                break;
            }

        } while (choose != 0);
    }
    catch (const ContactException &e)
    {
        std::cerr << "---> 操作通讯录时发现异常！！！" << std::endl
                  << "---> 异常信息：" << e.what() << std::endl;
    }
    catch (const std::exception &e)
    {
        std::cerr << "---> 操作通讯录时发现异常！！！" << std::endl
                  << "---> 异常信息：" << e.what() << std::endl;
    }

    return 0;
}